<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>项目横道图</title>
    <link href="../../Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="../../Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="../../Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="../../Content/js/common.js"></script>
    <link href="../../Content/themes/icon.css" rel="stylesheet" />
    <script src="../../jQuery.Gantt/gantt2/lib/date.js"></script>
    <script src="../../jQuery.Gantt/gantt2/SYPM.ganttView.js?v=2" charset="UTF-8"></script>
    <link href="../../jQuery.Gantt/gantt2/SYPM.ganttView.css?v=2" rel="stylesheet" />
    <link href="../../Content/themes/table.css" rel="stylesheet" />

    <!--
        -->

    <script>

       
        $(function () {
            $("#ganttChart").ganttView({
                dataUrl: "data.json?r=" + Math.random(),
				scale:"months",
                paradata: { view: "ProjectGantt", rows:6 },
                slideWidth: $(window).width() - 380,
                //afterload: function (data) { alert("数据加载完毕！！"+data);},
                behavior: {
                    //onClick: function (data) {
                    //    var msg = "点击事件: { start: " + data.start.toString("M/d/yyyy") + ", end: " + data.end.toString("M/d/yyyy") + " }";
                    //    $("#eventMessage").text(msg);
                    //},
                    //onResize: function (data) {
                    //    var msg = "调整事件: { start: " + data.start.toString("M/d/yyyy") + ", end: " + data.end.toString("M/d/yyyy") + " }";
                    //    $("#eventMessage").text(msg);
                    //}//,
                    // onDrag: function (data) {
                    //   var msg = "拖拽事件: { start: " + data.start.toString("M/d/yyyy") + ", end: " + data.end.toString("M/d/yyyy") + " }";
                    // $("#eventMessage").text(msg);
                    //}
                }
            });
            $('#pp').pagination({
                total: 2000,
                pageSize: 5,
                pageList: [5, 10, 15, 20],
                onSelectPage: function (pageNumber, pageSize) {
                    $(this).pagination('loading');
                    $("#ganttChart").ganttView("destroy", 0);
                    $("#ganttChart").ganttView({
                        dataUrl: "/Project/PMGanttJson?r=" + Math.random(),
                        paradata: {
                            view: "ProjectGantt", rows: pageSize, page: pageNumber, 
                            ProjectNo: $('#ProjectNo').val(),
                            ProjectName: $('#txtPMName').val(),
                            status: $('#FStatus').val(),
                            CreateTimeS: $('#txtAddBeginDate').datetimebox('getValue'),
                            CreateTimeE: $('#txtAddEndDate').datetimebox('getValue')
                        },
                        slideWidth: $(window).width() - 260,
                        behavior: {}
                    });
                    $(this).pagination('loaded');
                }
            });
            // $("#ganttChart").ganttView("setSlideWidth", 600);


            $('div.ganttview-vtheader-item-desc').resizable({
                maxWidth: 800,
                maxHeight: 600
            });

             $('div.ganttview-vtheader-item-name').resizable({
                maxWidth: 800,
                maxHeight: 600
             });


            //回车搜索
             $("#ui_pm_search").find('input').on('keyup', function (event) {
                 if (event.keyCode == '13') {
                     ui_pm_searchdata();
                 }
             })

        });

        //搜索任务单
        function ui_pm_searchdata() {
            $("#ganttChart").ganttView("destroy", 0);
            $("#ganttChart").ganttView({
                dataUrl: "/Project/PMGanttJson?r=" + Math.random(),
                paradata: {
                    view: "ProjectGantt",  
                    ProjectNo: $('#ProjectNo').val(),
                    ProjectName: $('#txtPMName').val(),
                    status: $('#FStatus').val(),
                    CreateTimeS: $('#txtAddBeginDate').datetimebox('getValue'),
                    CreateTimeE: $('#txtAddEndDate').datetimebox('getValue')
                },
                slideWidth: $(window).width() - 260,
                behavior: {}
            });
        }
        //清除搜索条件
        function ui_pm_cleardata() {
            $('#ui_pm_search input').val('');
            $('#ui_pm_search select').val('select');
            $('#txtAddBeginDate').datetimebox('setValue', '');
            $('#txtAddEndDate').datetimebox('setValue', ''); 
        }
        function ui_project_cleargantt() {
            $("#ganttChart").ganttView("destroy", 0);
        }

    </script>

</head>

<body>
    <div id="ui_pm_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'north',split:true,border:true,collapsed:true" title="条件搜索" style="height:104px;">
            <div id="ui_pm_search">
                <table class="tableForm" style="width: 99%; height: 100%; background: #F5F5F5;">
                    <tr>
                        <th>
                            项目编码：
                        </th>
                        <td>
                            <input name="ProjectNo" id="ProjectNo" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            项目名称：
                        </th>
                        <td>
                            <input name="txtPMName" id="txtPMName" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            项目状态：
                        </th>
                        <td>
                            <select name="FStatus" id="FStatus">
                                <option value="select">请选择</option>
                                <option value="0">未确认</option>
                                <option value="1">已确认</option>
                                <option value="2">已完成</option>
                            </select>
                        </td>

                    <tr>
                        <th>
                            添加时间：
                        </th>
                        <td>
                            <input name="txtAddBeginDate" id="txtAddBeginDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            至：
                        </th>
                        <td>
                            <input name="txtAddEndDate" id="txtAddEndDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>
                        <td colspan="4">
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" plain="true"
                               onclick="ui_pm_searchdata();">搜索</a>
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-clear" plain="true"
                               onclick="ui_pm_cleardata();">清空条件</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div data-options="region:'center',border:false">            
            <div id="ganttChart" data-options="fit:true,border:false"></div>
            <!-- <div id="pp" class="easyui-pagination" style="border:1px solid #ccc;"></div> -->
            <div id="eventMessage"></div>
        </div>
    </div>
    <div id="menu_display" class="easyui-menu" data-options="onClick:menuHandler" style="width:120px;">
      <!--  <div data-options="name:'pno',iconCls:''">项目编号</div> -->
        <div data-options="name:'pname',iconCls:''">项目名称</div>
        <div data-options="name:'pmgr',iconCls:''">管理员</div>
        <div data-options="name:'pdesc',iconCls:''">项目描述</div>
        <div data-options="name:'nodename',iconCls:''">节点名称</div>
        <div data-options="name:'exec',iconCls:''">执行人</div>
        <div data-options="name:'time',iconCls:''">完成时间</div>        
    </div>
    <script type="text/javascript">
        function menuHandler(item) {
            //alert(item.name);
            if (item.name == 'pno') {
                if ($('div.ganttview-vtheader-item-desc').is(':hidden')) {
                    $('div.ganttview-vtheader-item-desc').show();
                } else {
                    $('div.ganttview-vtheader-item-desc').hide();
                }
            } else if (item.name == 'pname') {
                if ($('div.ganttview-vtheader-item-name').is(':hidden')) {
                    $('div.ganttview-vtheader-item-name').show();
                } else { 
                    $('div.ganttview-vtheader-item-name').hide();
                }
            } else if (item.name == 'pmgr') {
                if ($('div.ganttview-vtheader-item-mgr').is(':hidden')) {
                    $('div.ganttview-vtheader-item-mgr').show();
                } else {
                    $('div.ganttview-vtheader-item-mgr').hide();
                }
            } else if (item.name == 'pdesc') {
                if ($('div.ganttview-vtheader-item-desc').is(':hidden')) {
                    $('div.ganttview-vtheader-item-desc').show();
                } else {
                    $('div.ganttview-vtheader-item-desc').hide();
                }
            } else if (item.name == 'nodename') {
                if ($('div.ganttview-vtheader-series-name').is(':hidden')) {
                    $('div.ganttview-vtheader-series-name').show();
                } else {
                    $('div.ganttview-vtheader-series-name').hide();
                }
            } else if (item.name == 'exec') {
                if ($('div.ganttview-vtheader-series-exec').is(':hidden')) {
                    $('div.ganttview-vtheader-series-exec').show();
                } else {
                    $('div.ganttview-vtheader-series-exec').hide();
                }
            } else if (item.name == 'time') {
                if ($('div.ganttview-vtheader-series-time').is(':hidden')) {
                    $('div.ganttview-vtheader-series-time').show();
                } else {
                    $('div.ganttview-vtheader-series-time').hide();
                }
            }     ;

    }
    </script>
</body>

</html>


